#!/usr/bin/python
# coding=utf-8

import plotly.plotly
import random
from plotly.graph_objs import *
import plotly.graph_objs as abc  # 必须
import numpy as np


class MarkLine:
    def __init__(self):
        print "欢迎使用点线图生成类"

    @staticmethod
    def sayHello(x, y, linename, filename):
        if x.__len__() != y.__len__(): return
        data_0 = abc.Scatter(
                x=x,
                y=y,
                name=linename,
                mode="lines+markers",
                marker=dict(
                        size=10,  # 点大小
                        color="rgba(0,47,167,.9)",  # 点颜色,r红色g绿色b蓝色,a亮度
                        line=dict(
                                width=2,  # 线大小
                                color='rgb(2,2,2)'  # 线颜色
                        )
                )
        )
        abc.layout = dict(title='QPS测试结果',
                          yaxis=dict(zeroline=False),
                          xaxis=dict(zeroline=False)
                          )
        # 多个数据组
        # data1 = Data([data_0,data_1, date_2, date_3])
        data1 = Data([data_0])
        fig = dict(data=data1, layout=abc.layout)
        plotly.offline.plot(fig, filename=filename + ".html")


if __name__ == "__main__":
    xx = [x * 10 for x in range(1,11)];
    y00 = [39.43373161402263, 58.74750323111268, 121.93634922570418, 119.52607909638284, 119.82706557895645,
           80.59623302161994, 66.29630932504945, 121.55029808311382, 113.95786935363378, 119.68436838369851];
    MarkLine.sayHello(xx, y00, "QPS", "test")
